{% extends 'common.html'%}
    {% block content %}

        <form class="layui-form">
            <div class="layui-form-item">
                <label for="business_name" class="layui-form-label">
                 <span class="we-red">*</span>功能名称
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="business_name" name="business_name" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="business_code" class="layui-form-label">
                 <span class="we-red">*</span>功能代码
                 </label>
                <div class="layui-input-block">
                    <input type="text" id="business_code" name="business_code" required="" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="business_desc" class="layui-form-label">
                 <span class="we-red">*</span>功能描述
                 </label>
                <div class="layui-input-block">
                    <textarea id="business_desc" name="business_desc" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="business_is_extra" class="layui-form-label">是否有额外参数</label>
                <div class="layui-input-block">
                  <input id="business_is_extra" type="checkbox" name="business_is_extra" lay-skin="switch">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="business_extra" class="layui-form-label">
                 额外参数
                 </label>
                <div class="layui-input-block">
                    <textarea id="business_extra" name="business_extra" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="add" lay-submit="">增加</button>
            </div>
		</form>


        <script type="text/javascript" src="/static/lib/layui/layui.js" charset="utf-8"></script>

        <script>
            layui.extend({
				admin: '/static/js/admin'
			});
			layui.use(['form','jquery', 'layer'], function() {
				var form = layui.form,
					$ = layui.jquery,
					layer = layui.layer;
				//监听提交
				form.on('submit(add)', function(data) {
					$.ajax({
                        type: 'post',
                        url: '/admin/business_add',
                        data: data.field,
                        success: function(data) {
                            layer.msg(data.message);
                            if(data.code ==1){
                               var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                            }

                        }
                    });
					return false;
				});

			});
        </script>

    {% endblock %}